/**
 * @author 
 * @time 
 * @description 实现路由定义和注册
 */

import { createRouter, createWebHistory } from "vue-router";
import interceptor from "./interceptor.js";

import Login from "../views/login/index.vue";
import Home from "../views/home/index.vue";
import PurchaseList from "../views/purchase/list.vue";
import PurchaseEdit from "../views/purchase/edit.vue";
import PurchaseDetails from "../views/purchase/details.vue";
import ProjectList from "../views/project/list.vue";
import ProjectEdit from "../views/project/edit.vue";
import My from "../views/my/index.vue";

/**实例化createRouter方法 */
const router = createRouter({
    /**路由模式 */
    history: createWebHistory(),
    /**路由规则 */
    routes: [
        { path: '/', redirect: '/login' },
        { path: '/login', component: Login, meta: { noLogin: true } },
        { path: '/home', component: Home },
        { path: '/purchase/list', component: PurchaseList },
        { path: '/purchase/edit', component: PurchaseEdit },
        { path: '/purchase/details', component: PurchaseDetails },

        { path: '/project/list', component: ProjectList },
        { path: '/project/edit', component: ProjectEdit },
        { path: '/my', component: My }

    ]
})

/**全局守卫 */
router.beforeEach(interceptor)

export default router